{include file='comdir/head.html'}
<body>
<div class="content">
	<div class="animated fadeInDown">
		<div class="pos"><a href="#" onClick="javascript :history.back(-1);">返回上一页</a></div>
		<div class="form-inline">
			<!-- 默认添加分类栏目 -->
			<label class="control-label">当前站点:</label>
			<select class="form-control sitesid_readonly back_inline" name="sitesid">
				{foreach from=$sitesselected item=vo}
				<option {if $default_sitesid==$vo.id} selected {/if} value="{$vo.id}">{$vo.name}</option>
				{/foreach}
			</select>
		</div>
		<div class="btn-box">
			<button class="btn btn-sm btn-success columnadd back_inline">添加栏目</button>
		</div>
		<div class="table_list_wrap">
			<div class="table-responsive">
				<table class="table table-bordered table-hover">
					<thead>
						<tr>
							<th>ID</th>
							<th>栏目logo</th>
							<th>栏目名称</th>
							<!-- <th>是否拷贝栏目</th> -->
							<th>共享栏目</th>
							<th>栏目类型</th>
							<th>站点</th>
							<th>是否导航显示</th>
							<th>是否下拉菜单</th>
							<th>文章数</th>
							<th>创建时间</th>
							<th width="100">排序</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody class="listtbody">
					
					{foreach from=$list item=vo}
					<tr class="column_{$vo.colid}">
							<td>{$vo.colid}</td>
							<td><img style="max-widht:100px;max-height:30px;" src='{$getConfig.upload_http}{$vo.photourl}' ></td>
							<td class="depth_{$vo.depth}" style="text-align: left;">{$vo.name}</td>
							<!-- <td>{if $vo.iscopy==1}是{else}否{/if}</td> -->
							<td>{$vo.copycolumnname}</td>
							<td>{if $vo.coltype==0}分类栏目{elseif $vo.coltype==1}系统栏目{elseif $vo.coltype==2}外链栏目{/if}</td>
							<td>{$vo.sitesname}</td>
							<td>{if $vo.showintop==1}是{else}否{/if}</td>
							<td>{if $vo.navimenu==1}是{else}否{/if}</td>
							<td>{$vo.infonum}</td>
							<td>{$vo.addtime|date_format:'%Y-%m-%d %H:%M:%S'}</td>
							<td><input type="text"  class="form-control editorderid" data-colid='{$vo.colid}' data-orderid='{$vo.orderid}' name="orderid" value='{$vo.orderid}'></td>
							<td>
								<input type="button" onclick="edit({$vo.colid})" class="btn btn-xs btn-warning" value="编辑">
								<input type="button" onclick="del({$vo.colid})" class="btn btn-xs btn-danger" value="删除">
							</td>
					</tr>
					{/foreach}
					</tbody>
				</table>
			</div>
		</div>

	</div>
</div>
<script type="text/javascript">
var _URL='{$_URL}';
var _getConfig='{$getConfig.upload_http}';
{literal}
$(function(){
	//添加栏目 默认添加分类栏目
	$('.columnadd').click(function(){
		var sitesid=$('.sitesid_readonly').val();
		window.location.href=_URL+"Column/add?sitesid="+sitesid+"&addcolumn=1";
	})
	//站点选择
	$('.sitesid_readonly').change(function(){
		var sitesid=$(this).val();
		var url=_URL+"Column/lists?sitesid="+sitesid;
		_ajaxs.post(url,'sitesid='+sitesid,function(data){
			$('.listtbody').html('');
			$('.listtbody').html(data);
		},'html');
	})
	//更新排序
	$('.editorderid').blur(function(){
		var url=_URL+"Column/edit";
		var orderid=$(this).val();
		var colid=$(this).attr('data-colid');
		var orderid_old=$(this).attr('data-orderid');
		if(orderid==orderid_old){
			return false;
		}
		_ajaxs.post(url,"editorderid=1&orderid="+orderid+"&colid="+colid,function(data){
			layer.msg(data.msg,{icon: 1}, function(){});
		});
	})
})
//编辑栏目
function edit(colid){
	window.location.href=_URL+"Column/edit?colid="+colid;
}
//删除栏目
function del(colid){
	var url=_URL+"Column/del";
	var del_all=layer.confirm('确认要删除吗！', {btn: ['确认','取消'],'title':'站点'},function(){
		_ajaxs.post(url,'colid='+colid,function(data){
			layer.msg(data.msg,{icon: 1}, function(){});
			if(data.status){
				$('.column_'+colid).remove();
			}
			layer.close(index);
		})
	});
}
{/literal}
</script>

</body>
</html>